# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.su>

_basename=pyimgui
_realname=imgui
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.0.0
_imguiver=1.82
pkgrel=3
pkgdesc='Cython-based Python bindings for dear imgui (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/pyimgui/pyimgui'
msys2_references=(
  'purl: pkg:pypi/imgui'
)
license=('spdx:MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-glfw"
         "${MINGW_PACKAGE_PREFIX}-python-pyopengl")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-click"
             "${MINGW_PACKAGE_PREFIX}-cython0"
             "${MINGW_PACKAGE_PREFIX}-cc")
options=(!strip)
source=("${url}/archive/${pkgver}/${_basename}-${pkgver}.tar.gz"
        "https://github.com/ocornut/imgui/archive/v${_imguiver}/imgui-${_imguiver}.tar.gz")
sha256sums=('4459241e8a0f6c802b420058fa30561750e8db5f33c6aea587c4732019e60c43'
            'fefa2804bd55f3d25b134af08c0e1f86d4d059ac94cef3ee7bd21e2f194e5ce5')

prepare() {
  cd "${srcdir}"
  rm -rf "python-build-${MSYSTEM}" | true
  rm -rf "${_basename}-${pkgver}"/imgui-cpp | true
  cp -r "${_basename}-${pkgver}" "python-build-${MSYSTEM}"
  cp -r "imgui-${_imguiver}" "python-build-${MSYSTEM}/imgui-cpp"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    "${MINGW_PREFIX}"/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}

# vim: ts=2 sw=2 et:
